import request from "@/request/request";
import requestMock from "@/request/requestMock";
// 请求三级分类列表
export const reqCategoryList = () => {
  return request.get("/product/getBaseCategoryList");
};

// 请求轮播图的mock数据
export const reqBannerList = () => {
  return requestMock.get("/home/banner");
};

// 请求首页的floor数据
export const reqFloorList = () => {
  return requestMock.get("/home/floor");
};

// 请求搜索页数据
export const reqSearchList = (searchParams) => {
  return request.post("/list", searchParams)
}

// 请求单个商品数据
export const reqGoodDetail = (skuId) => {
  return request.get(`/item/${skuId}`);
};

// 添加购物车和对已有商品数量修改
export const reqAddCartOrUpdataCart = (skuId, skuNum) => {
  return request.post(`/cart/addToCart/${skuId}/${skuNum}`);
};

// 获取购物车列表
export const reqCartList = () => {
  return request.get(`/cart/cartList`);
};

// 删除单个物品
export const reqdeleteCartList = (skuId) => {
  return request.delete(`/cart/deleteCart/${skuId}`);
};

// 修改单个状态
export const reqChangeChecked = (skuId, isChecked) => {
  return request.get(`/cart/checkCart/${skuId}/${isChecked}`);
};

// 全选商品
export const reqChangeAllChecked = (isChecked, skuIdList) => {
  return request.post(`/cart/batchCheckCart/${isChecked}`, skuIdList);
};

// 删除已选中
export const reqDeleteAllCart = (skuIdList) => {
  return request.delete(`/cart/batchDeleteCart`, {
    data:skuIdList
  });
};

// 获取验证码
export const reqVerifyCode = (phone) => {
  return request.get(`/user/passport/sendCode/${phone}`);
};

// 注册
export const reqRegister = (userInfo) => {
  return request.post(`/user/passport/register`, userInfo);
};

// 登录
export const reqLogin = (userInfo) => {
  return request.post(`/user/passport/login`, userInfo);
};

// 请求用户信息（携带token）
export const reqUserInfo = ()=>{
  return request.get(`/user/passport/auth/getUserInfo`)
}

// 退出登陆
export const reqLogout = ()=>{
  return request.get(`/user/passport/logout`)
}

// 请求用户地址的mock数据
export const reqAddressMock = ()=>{
  return requestMock.get(`/user/userAddress/auth/findUserAddressList`)
}

// 请求交易页数据
export const reqTradeInfo = ()=>{
  return request.get(`/order/auth/trade`)
}

// 获取订单列表
export const reqOrder = (tradeNo,tradeDetail) =>{
  return request.post(`/order/auth/submitOrder?tradeNo=${tradeNo}`,tradeDetail)
}

// 根据订单号获得完整的支付信息
export const reqPayInfo = (orderId) => {
  return request.get(`/payment/weixin/createNative/${orderId}`)
};

// 根据订单查看支付状态
export const reqPayState = (orderId)=>{
  return request.get(`/payment/weixin/queryPayStatus/${orderId}`)
}

// 获取订单的分页列表
export const reqOrderList = ({page,limit})=>{
  return request.get(`/order/auth/${page}/${limit}`)
}